﻿var 
	less = require('gulp-less'),
	browserSync = require('browser-sync'),
	fileinclude = require('gulp-file-include');

const { src, watch, series, parallel, task, dest} = require('gulp');

function less_build(cb) {
	src('src/less/*.less')
	.pipe(less())
	.pipe(dest('static/public/css'));
	cb()
}

function html_build(cb) {
	src('src/views/report/*.html')
	.pipe(fileinclude({
		prefix: '@@',
		basepath: 'src/includes'
	}))
	.pipe(dest('./static/report'));
	cb()
}

function watch_tsk(cb) {
	watch('less/*.less', function(cb2){
		less_build(cb2)
	});
	cb()
}

function browser_sync(cb) {
	browserSync.init({
		server: {
			baseDir: "./"
		},
		port:2333,
		ui: {
			port: 2111
		}
    });
    //监听任何文件变化，实时刷新页面
	watch(["css/**/*.*","index.html"], function(cb2){
		browserSync.reload()
		cb2()
	});
	cb()
}

exports.default = series(watch_tsk, browser_sync)